package com.fyf.game.net.server;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

import com.fyf.game.net.ReceiveHandler;
import com.fyf.game.net.SenderBox;

/**
 * @author fanyifeng 2013-1-9 下午3:23:07
 */
public class RunEnvir
{
	public int					serverPort			= 0;
	public boolean				isServerStart		= false;

	public final AtomicLong		successReadMsgCount	= new AtomicLong(0);

	public final AtomicLong		successAcceptCount	= new AtomicLong(0);
	public final AtomicLong		errorAcceptCount	= new AtomicLong(0);

	public final AtomicLong		errorReadCount		= new AtomicLong(0);
	public final AtomicLong		errorWriteCount		= new AtomicLong(0);
	public final AtomicLong		successOutLine		= new AtomicLong(0);

	public final AtomicInteger	closeCount			= new AtomicInteger(0); // 结束计数器
	public Transporter[]		tsps				= new Transporter[0];	// 初始化替换掉

	final SenderBox				senderBox			= new SenderBox();		// SenderBox

	public int transporterCount() {
		return tsps.length;
	}

	public int senderSize() {
		return senderBox.size();
	}

	void initTransporters(int count, ReceiveHandler handler) {
		tsps = new Transporter[count];
		for (int i = 0; i < tsps.length; ++i) {
			tsps[i] = new Transporter(handler).setEnvir(this);
		}
	}

}
